<div class="comment" id="comment_div">
    <h3>留言/评论</h3>
    <div class="editor">
        <?php if ( $validUser )
        { ?>
            <?php echo form_open( my_url( 'post', 'comment', '', false), array( 'id' => 'commentform', 'onsubmit' => 'return chk_comment();' ), array( 'postid' => $postId ) ); ?>
            <?php echo form_textarea( array( 'id' => 'content', 'name' => 'content' ) ); ?>
            <?php echo form_submit( array( 'id' => 'commentbtn', 'value' => '留言', 'class' => 'btn', 'name' => 'submit' ) ); ?>
            <?php create_token(); ?>
            <?php echo form_close(); ?>
            <?php init_kindeditor( 'content', '100%', 150 ); ?>
            <script type="text/javascript">
                function chk_comment()
                {
                    if ( editor.html() == '' )
                    {
                        alert('请填写留言内容');
                        return false;
                    }
                    return true;
                }
          </script>
        <?php }
        else
        { ?>
            <p class="notice">请先<a href="<?php my_url( 'login' ); ?>">登录</a>，后才能评论/留言</p>
<?php } ?>
    </div>
    <div class="r">
        <h3>已有留言/评论(<?php echo count( $commentData ); ?>)</h3>
        <ul class="list">
            <?php if(empty($commentData)){ ?>
            <li>暂没有任何评论</li>
            <?php
            } else {
                foreach( $commentData as $commentId => $comment ) {
                    $isReply = isset( $commentData[$comment['id']] );
                    $replyTo = ( $isReply ) ? $commentData[$comment['id']]['username'] : '';
          ?>
            <li<?php if($isReply){ ?> class="reply"<?php } ?>>
                <p class="arg">
                    <?php if($replyTo){ ?>
                    <strong>回复 <?php echo $replyTo; ?></strong>
                    <?php } else { ?>
                    <strong><?php echo $comment['username']; ?></strong>
                    <?php } ?>
                    <span class="commenttime"><?php echo my_dateformat($comment['addtime']); ?></span>
                </p>
                <p><?php echo $comment['content']; ?></p>
            </li>
            <?php
                }
            }
          ?>
        </ul>
<!--        <ul class="page">
            <li>
                <span class="active">1</span>
            </li>
            <li>
                <a href="#">2</a>
            </li>
        </ul>-->
    </div>
    <div class="c"></div>
</div>